<script setup>
import { getStorage, setStorage, clearStorage, removeStorage } from '~/composables/storage'

const userStore = useUserStore()



const isLine = getStorage('isLine')






const copyToClipboard = (content) => {
  const textarea = document.createElement("textarea")
  textarea.value = content
  document.body.appendChild(textarea)
  textarea.select()
  document.execCommand("Copy")
  textarea.remove()
  toast('复制成功')
}


const copyFn = (value) => {
  copyToClipboard(value)
}


const router = useRouter()

const logOut = () => {

  userStore.token = ''
  userStore.userInfo = ''
  router.push('/login')

}

const ruleForm = reactive({
  bbinfo: '', //版本信息
  email: '',//邮箱
  gw: '',//官网
  phone: '',//联系方式
  rzaddress: '',//日志保存地址
  sjaddress: '',//数据保存地址
  wxgzh: '',//微信公众号
  xcx: '',//小程序
  xtfzrname: '',//系统负责人姓名
  issc: false,//是否上传云端 0 不上传 1 上传
  lightip: '',//模块箱灯光ip
  lightcom: '',//模块箱灯光端口
  id: 1
})


const dialogVisible = ref(false)


const getData = () => {
  tInfoSelbyid().then(res => {
    Object.keys(ruleForm).forEach(v => {
      ruleForm[v] = res.result[v]
    })
    ruleForm.issc = res.result.issc == 1 ? true : false
  })


}
getData()


const dblclickFn = () => {
  if (userStore.userInfo.auth == 0) return
  dialogVisible.value = true
}

const closeFn = () => getData()

const submitForm = () => {
  let Q = { ...ruleForm }
  Q.issc = ruleForm.issc ? 1 : 0
  tInfoUpdate(Q).then(res => {
    console.log(res)
    dialogVisible.value = false
  })
}



const changecheck = (e) => {
  let Q = {
    "id": userStore.userInfo.id,
    "iscc": e ? 1 : 0
  }
  tInfoIsscyd(Q).then(res => {
    toast('修改成功')
  })
}
</script>

<template>
  <div class="flex flex-col flex-1 px-[60px] justify-around pb-[50px]">
    <div class="h-[13%] w-full"></div>
    <div class="flex items-center" v-if="isLine">
      <svg t="1721572653850" class="icon  xwmd:(w-[100px] h-[100px]) xwlg:(w-[80px] h-[80px])" viewBox="0 0 1024 1024"
        version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4316" width="200" height="200">
        <path
          d="M855.04 385.024q19.456 2.048 38.912 10.24t33.792 23.04 21.504 37.376 2.048 54.272q-2.048 8.192-8.192 40.448t-14.336 74.24-18.432 86.528-19.456 76.288q-5.12 18.432-14.848 37.888t-25.088 35.328-36.864 26.112-51.2 10.24l-567.296 0q-21.504 0-44.544-9.216t-42.496-26.112-31.744-40.96-12.288-53.76l0-439.296q0-62.464 33.792-97.792t95.232-35.328l503.808 0q22.528 0 46.592 8.704t43.52 24.064 31.744 35.84 12.288 44.032l0 11.264-53.248 0q-40.96 0-95.744-0.512t-116.736-0.512-115.712-0.512-92.672-0.512l-47.104 0q-26.624 0-41.472 16.896t-23.04 44.544q-8.192 29.696-18.432 62.976t-18.432 61.952q-10.24 33.792-20.48 65.536-2.048 8.192-2.048 13.312 0 17.408 11.776 29.184t29.184 11.776q31.744 0 43.008-39.936l54.272-198.656q133.12 1.024 243.712 1.024l286.72 0z"
          p-id="4317"></path>
      </svg>

      <div class="font-semibold   ml-[40px] xwmd:(text-[40px]) xwlg:(text-[30px])">保存位置</div>
    </div>


    <div class="flex g-[50px]" v-if="isLine">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])">数据保存路径</div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">默认将监测数据储在此文件夹中（一天一次）保存格式：DW01年月日</div>
    </div>


    <div class="flex g-[50px] items-center" v-if="isLine">
      <div class="w-[20%] flex justify-end">
        <svg t="1721572995118" class="icon  xwmd:(w-[80px]) xwlg:(w-[50px])" viewBox="0 0 1024 1024" version="1.1"
          xmlns="http://www.w3.org/2000/svg" p-id="6356" width="80" height="80">
          <path d="M0 0h1024v1024H0V0z" fill="#202425" opacity=".01" p-id="6357"></path>
          <path
            d="M102.4 68.266667a34.133333 34.133333 0 0 1 34.133333-34.133334h750.933334a34.133333 34.133333 0 0 1 34.133333 34.133334v634.402133a34.133333 34.133333 0 0 1-10.001067 24.132267l-253.064533 253.064533a34.133333 34.133333 0 0 1-24.132267 10.001067H136.533333a34.133333 34.133333 0 0 1-34.133333-34.133334V68.266667z"
            fill="#11AA66" p-id="6358"></path>
          <path
            d="M238.933333 238.933333a34.133333 34.133333 0 0 1 34.133334-34.133333h477.866666a34.133333 34.133333 0 1 1 0 68.266667H273.066667a34.133333 34.133333 0 0 1-34.133334-34.133334z m0 204.8a34.133333 34.133333 0 0 1 34.133334-34.133333h477.866666a34.133333 34.133333 0 1 1 0 68.266667H273.066667a34.133333 34.133333 0 0 1-34.133334-34.133334z m34.133334 170.666667a34.133333 34.133333 0 1 0 0 68.266667h204.8a34.133333 34.133333 0 1 0 0-68.266667H273.066667z"
            fill="#FFFFFF" p-id="6359"></path>
          <path
            d="M648.533333 750.933333a34.133333 34.133333 0 0 1 34.133334-34.133333h230.7072a3.413333 3.413333 0 0 1 2.389333 5.802667l-261.393067 261.461333a3.413333 3.413333 0 0 1-5.8368-2.423467V750.933333z"
            fill="#FFAA44" p-id="6360"></path>
        </svg>
      </div>
      <div class="flex-1 text-[30px] flex items-center xwmd:( h-[80px]) xwlg:( h-[50px])">
        <el-input v-model="ruleForm.sjaddress" class="h-full w-[50%]" disabled placeholder="暂未配置路径" />

        <div class="flex items-center items-center  h-[100%] ml-[50px]">
          <el-button @click="copyFn(ruleForm.sjaddress)"
            class="w-full h-full rounded-[10px] flex justify-center items-center" color="#009757">
            <span class=" font-medium text-white xwmd:( text-[26px]) xwlg:( text-[16px])">复制路径 </span>
          </el-button>
        </div>
      </div>
    </div>


    <div class="flex g-[50px]" v-if="isLine">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])">日志保存路径</div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">默认将日志存储在此文件夹中（一月一次）   保存格式：log年月</div>
    </div>


    <div class="flex g-[50px] items-center" v-if="isLine">
      <div class="w-[20%] flex justify-end">
        <svg t="1721573469129" class="icon  xwmd:(w-[100px]) xwlg:(w-[66px])" viewBox="0 0 1024 1024" version="1.1"
          xmlns="http://www.w3.org/2000/svg" p-id="7501" width="80" height="80">
          <path
            d="M791.94 155.36H332.48c-42.23 0-76.54 34.31-76.54 76.54v76.55h-51.03c-28.16 0-51.04 22.87-51.04 51.03v306.37c0 28.15 22.88 51.02 51.04 51.02h51.03v76.54c0 42.24 34.32 76.55 76.54 76.55h459.46c42.23 0 76.54-34.32 76.54-76.54V231.9c0.1-42.24-34.31-76.54-76.54-76.54z m-547.68 298.6h40.28l26.04 93.58h5.7l29.16-93.58h34.45l29.02 93.71h6.24l26.18-93.71h40.41l-40.41 133.72H384.1l-19.53-70.25h-5.43l-19.26 69.98h-55.74l-39.88-133.45zM817.45 793.5c-0.01 14.09-11.42 25.5-25.51 25.51H332.48c-14.09-0.01-25.5-11.43-25.51-25.51v-76.54h204.21c28.15 0 51.03-22.88 51.03-51.03V614.9H740.9c14.09-0.01 25.51-11.43 25.52-25.52-0.02-14.09-11.43-25.5-25.52-25.51H562.21v-51.03H740.9c14.09-0.01 25.51-11.43 25.52-25.52-0.01-14.09-11.43-25.5-25.52-25.52H562.21v-51.03H740.9c14.09-0.01 25.51-11.43 25.52-25.51-0.01-14.09-11.43-25.51-25.52-25.52H562.21c0-28.16-22.89-51.03-51.03-51.03H306.97v-76.54c0.01-14.09 11.43-25.5 25.51-25.52h459.46c14.08 0.01 25.5 11.43 25.51 25.52V793.5z m0 0"
            fill="#54A0FF" p-id="7502"></path>
        </svg>
      </div>
      <div class="flex-1 text-[30px] flex items-center xwmd:( h-[80px]) xwlg:( h-[50px])">
        <el-input v-model="ruleForm.rzaddress" class="h-full w-[50%]" disabled placeholder="暂未配置路径" />

        <div class="flex items-center items-center  h-[100%] ml-[50px]">
          <el-button @click="copyFn(ruleForm.rzaddress)"
            class="w-full h-full rounded-[10px] flex justify-center items-center" color="#009757">
            <span class=" font-medium text-white xwmd:( text-[26px]) xwlg:( text-[16px])">复制路径 </span>
          </el-button>
        </div>
      </div>
    </div>












    <div class="flex items-center" v-if="isLine">
      <div class="w-[14.5%]  xwmd:(text-[30px]) xwlg:(text-[20px])">联网服务</div>
      <div class="flex items-center">
        <svg t="1721573563546" class="icon  xwmd:(w-[80px]) xwlg:(w-[50px])" viewBox="0 0 1024 1024" version="1.1"
          xmlns="http://www.w3.org/2000/svg" p-id="8569" width="80" height="80">
          <path
            d="M815.104 363.008a307.2 307.2 0 0 0-606.72 0A256 256 0 0 0 256 870.4h204.8v-204.8H358.4l153.6-204.8 153.6 204.8h-102.4v204.8h204.8a256 256 0 0 0 47.104-507.392z"
            fill="#333333" p-id="8570"></path>
        </svg>
        <el-checkbox @change="changecheck" class="mx-[30px]" v-model="ruleForm.issc" label="上传云端" size="large" />

        <n-tooltip trigger="hover" placement="top">
          <template #trigger>
            <svg t="1721574463830" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
              p-id="10295" width="30" height="30">
              <path
                d="M512 853.333333c-187.733333 0-341.333333-153.6-341.333333-341.333333s153.6-341.333333 341.333333-341.333333 341.333333 153.6 341.333333 341.333333-153.6 341.333333-341.333333 341.333333z m0-85.333333c140.8 0 256-115.2 256-256s-115.2-256-256-256-256 115.2-256 256 115.2 256 256 256z m42.666667-170.666667v85.333334h-85.333334v-85.333334h85.333334z m0-256v213.333334h-85.333334V341.333333h85.333334z"
                fill="#444444" p-id="10296"></path>
            </svg>
          </template>
          <div class="text-white">
            勾选”上传云端“，即可享受小程序远程推送服务
          </div>
        </n-tooltip>




      </div>
    </div>


    <div class="flex items-center">
      <svg @dblclick="dblclickFn" t="1721574842966" class="icon xwmd:(w-[100px] h-[100px]) xwlg:(w-[80px] h-[80px]) "
        viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12361" width="80" height="80">
        <path
          d="M516.251837 958.322162c-246.49809 0-446.321138-199.826118-446.321138-446.321138S269.753747 65.677838 516.251837 65.677838c246.496044 0 446.321138 199.828165 446.321138 446.323185S762.747881 958.322162 516.251837 958.322162zM516.251837 261.625626c-30.060643 0-54.429657 24.369014-54.429657 54.42761 0 30.062689 24.369014 54.431703 54.429657 54.431703 30.060643 0 54.429657-24.369014 54.429657-54.431703C570.681494 285.99464 546.31248 261.625626 516.251837 261.625626zM570.681494 479.343229c0-24.048719-19.497053-43.543725-43.543725-43.543725l-21.771863 0c-24.048719 0-43.543725 19.493983-43.543725 43.543725l0 261.261329c0 24.046672 19.493983 43.543725 43.543725 43.543725l21.771863 0c24.046672 0 43.543725-19.497053 43.543725-43.543725L570.681494 479.343229z"
          fill="#3A2E2E" p-id="12362"></path>
      </svg>

      <div class="font-semibold   ml-[40px] xwmd:(text-[40px]) xwlg:(text-[30px])">关于希姆西</div>





    </div>






    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])">版本信息</div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">{{ ruleForm.bbinfo }}</div>
    </div>

    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])">了解更多</div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">
        官网：
        <a :href="ruleForm.gw">
          {{ ruleForm.gw }}
        </a>
      </div>
    </div>


    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])"></div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">微信公众号：{{ ruleForm.wxgzh }}</div>
    </div>


    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])"></div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">搜索小程序：{{ ruleForm.xcx }}</div>
    </div>

    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])"></div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">系统负责人姓名：{{ ruleForm.xtfzrname }}</div>
    </div>

    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])"></div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">邮箱：{{ ruleForm.email }}</div>
    </div>

    <div class="flex g-[50px]">
      <div class="w-[20%]  xwmd:(text-[30px]) xwlg:(text-[20px])"></div>
      <div class="flex-1 xwmd:(text-[30px]) xwlg:(text-[20px])">联系方式：{{ ruleForm.phone }}</div>
    </div>

    <div>
      <el-button class="w-[188px]  rounded-[10px] flex justify-center items-center ml-auto" color="#009757"
        @click="logOut">
        <span class="text-[16px] font-medium text-white">退出系统</span>
      </el-button>
    </div>







    <el-dialog v-model="dialogVisible" title="编辑信息" width="300px" top="20vh" @close="closeFn">
      <div class="flex justify-center gap-[30px]">
        <div class="flex-1 flex flex-col items-center">


          <el-form ref="ruleFormRef" :model="ruleForm" label-width="auto" style="width: 100%;"
            class="demo-ruleForm flex-1" status-icon>

            <el-form-item label="版本信息">
              <el-input v-model="ruleForm.bbinfo" />
            </el-form-item>

            <el-form-item label="邮箱">
              <el-input v-model="ruleForm.email" />
            </el-form-item>

            <el-form-item label="官网">
              <el-input v-model="ruleForm.gw" />
            </el-form-item>

            <el-form-item label="联系方式">
              <el-input v-model="ruleForm.phone" />
            </el-form-item>

            <el-form-item label="日志保存地址">
              <el-input v-model="ruleForm.rzaddress" />
            </el-form-item>

            <el-form-item label="数据保存地址">
              <el-input v-model="ruleForm.sjaddress" />
            </el-form-item>

            <el-form-item label="微信公众号">
              <el-input v-model="ruleForm.wxgzh" />
            </el-form-item>


            <el-form-item label="小程序">
              <el-input v-model="ruleForm.xcx" />
            </el-form-item>

            <el-form-item label="系统负责人姓名">
              <el-input v-model="ruleForm.xtfzrname" />
            </el-form-item>


            <el-form-item label="是否上传云端" class="flex items-center">
              <el-checkbox class="" v-model="ruleForm.issc" size="large" />
            </el-form-item>


            <el-form-item label="模块箱灯光ip">
              <el-input v-model="ruleForm.lightip" />
            </el-form-item>

            <el-form-item label="模块箱灯光端口">
              <el-input type="number" v-model="ruleForm.lightcom" />
            </el-form-item>




          </el-form>




        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="dialogVisible = false">取消</el-button>
          <el-button type="primary" @click="submitForm()">
            <span class="text-white">确定</span>
          </el-button>
        </div>
      </template>
    </el-dialog>










  </div>
</template>

<style  scoped></style>